require 'sinatra/base'
require 'rest_base/exceptions'

module RestBase
  class Application < Sinatra::Base
    error RestBase::Exceptions::InvalidRequest do
      cur_error = env["sinatra.error"]
      errors = [cur_error.message]

      cur_error.invalid_params.each { |param, message|
        errors << "#{param.to_s} is not valid: #{message}"
      }

      errors
    end
  end
end